﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.66    渠道信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_REST_CHANNEL: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_REST_CHANNEL()
		{}
		#region Model
		private long _id;
		private string _intername;
		private string _addr;
		private string _mobile1;
		private string _mobile2;
		private string _qq;
		private string _email;
		private string _implevel;
		private string _remark;
		private Nullable<DateTime> _createdate;
		private string _createby;
		private int _deleteflag;
		private Nullable<DateTime> _deletedate;
		private string _deleteby;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 中介人名称
		/// </summary>
		[DataMember]
		public string INTERNAME
		{
			get{return _intername;}
			set{
				if ( _intername!= value)
				{
					 _intername = value;
					OnPropertyChanged("INTERNAME");
				}
			}
		}
		/// <summary>
		/// 地址
		/// </summary>
		[DataMember]
		public string ADDR
		{
			get{return _addr;}
			set{
				if ( _addr!= value)
				{
					 _addr = value;
					OnPropertyChanged("ADDR");
				}
			}
		}
		/// <summary>
		/// 手机号1
		/// </summary>
		[DataMember]
		public string MOBILE1
		{
			get{return _mobile1;}
			set{
				if ( _mobile1!= value)
				{
					 _mobile1 = value;
					OnPropertyChanged("MOBILE1");
				}
			}
		}
		/// <summary>
		/// 手机号2
		/// </summary>
		[DataMember]
		public string MOBILE2
		{
			get{return _mobile2;}
			set{
				if ( _mobile2!= value)
				{
					 _mobile2 = value;
					OnPropertyChanged("MOBILE2");
				}
			}
		}
		/// <summary>
		/// QQ
		/// </summary>
		[DataMember]
		public string QQ
		{
			get{return _qq;}
			set{
				if ( _qq!= value)
				{
					 _qq = value;
					OnPropertyChanged("QQ");
				}
			}
		}
		/// <summary>
		/// Email
		/// </summary>
		[DataMember]
		public string EMAIL
		{
			get{return _email;}
			set{
				if ( _email!= value)
				{
					 _email = value;
					OnPropertyChanged("EMAIL");
				}
			}
		}
		/// <summary>
		/// 重要级别
		/// </summary>
		[DataMember]
		public string IMPLEVEL
		{
			get{return _implevel;}
			set{
				if ( _implevel!= value)
				{
					 _implevel = value;
					OnPropertyChanged("IMPLEVEL");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 登记时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 登录人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 删除状态0否,1是
		/// </summary>
		[DataMember]
		public int DELETEFLAG
		{
			get{return _deleteflag;}
			set{
				if ( _deleteflag!= value)
				{
					 _deleteflag = value;
					OnPropertyChanged("DELETEFLAG");
				}
			}
		}
		/// <summary>
		/// 删除时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> DELETEDATE
		{
			get{return _deletedate;}
			set{
				if ( _deletedate!= value)
				{
					 _deletedate = value;
					OnPropertyChanged("DELETEDATE");
				}
			}
		}
		/// <summary>
		/// 删除人
		/// </summary>
		[DataMember]
		public string DELETEBY
		{
			get{return _deleteby;}
			set{
				if ( _deleteby!= value)
				{
					 _deleteby = value;
					OnPropertyChanged("DELETEBY");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

